package com.jeasonzhao.commons.xml;

import com.jeasonzhao.commons.basic.StringCollection;

public class XMLNodeCollection extends java.util.Vector<XMLNode>
{
    private static final long serialVersionUID = 1L;
    public XMLNodeCollection()
    {
        super();
    }

    public StringCollection valueOf(String ...attributesNames)
    {
        StringCollection ret = new StringCollection();
        for(XMLNode node : this)
        {
            if(null == node)
            {
                continue;
            }
            String strValue = node.valueOf(attributesNames);
            if(null != strValue)
            {
                ret.add(strValue);
            }
        }
        return ret;
    }

    public StringCollection subItemOrValueOf(String ...attributesNames)
    {
        StringCollection ret = new StringCollection();
        for(XMLNode node : this)
        {
            if(null == node)
            {
                continue;
            }
            String strValue = node.subItemOrValueOf(attributesNames);
            if(null != strValue)
            {
                ret.add(strValue);
            }
        }
        return ret;
    }

    public XMLNodeCollection selectNodes(String ...names)
    {
        XMLNodeCollection ret = new XMLNodeCollection();
        for(XMLNode node : this)
        {
            if(null == node)
            {
                continue;
            }
            XMLNodeCollection v = node.selectNodes(names);
            if(null != names)
            {
                ret.addAll(v);
            }
        }
        return ret;

    }
}
